summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/svc/svc_secure_monitor_call.cpp
blob: 62c7815516b07781bd62788dc6a6f543d5d85b5e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "core/core.h"
#include "core/hle/kernel/physical_core.h"
#include "core/hle/kernel/svc.h"

namespace Kernel::Svc {

void CallSecureMonitor(Core::System& system, lp64::SecureMonitorArguments* args) {
    UNIMPLEMENTED();
}

void CallSecureMonitor64(Core::System& system, lp64::SecureMonitorArguments* args) {
    CallSecureMonitor(system, args);
}

void CallSecureMonitor64From32(Core::System& system, ilp32::SecureMonitorArguments* args) {
    // CallSecureMonitor64From32 is not supported.
    UNIMPLEMENTED_MSG("CallSecureMonitor64From32");
}

// Custom ABI for CallSecureMonitor.

void SvcWrap_CallSecureMonitor64(Core::System& system) {
    auto& core = system.CurrentPhysicalCore().ArmInterface();
    lp64::SecureMonitorArguments args{};
    for (int i = 0; i < 8; i++) {
        args.r[i] = core.GetReg(i);
    }

    CallSecureMonitor64(system, std::addressof(args));

    for (int i = 0; i < 8; i++) {
        core.SetReg(i, args.r[i]);
    }
}

void SvcWrap_CallSecureMonitor64From32(Core::System& system) {
    auto& core = system.CurrentPhysicalCore().ArmInterface();
    ilp32::SecureMonitorArguments args{};
    for (int i = 0; i < 8; i++) {
        args.r[i] = static_cast<u32>(core.GetReg(i));
    }

    CallSecureMonitor64From32(system, std::addressof(args));

    for (int i = 0; i < 8; i++) {
        core.SetReg(i, args.r[i]);
    }
}

} // namespace Kernel::Svc